//
//  ClassificationTouristController.swift
//  AirTravel
//
//  Created by apple on 2021/7/28.
//

import UIKit

class ClassificationTouristController: UIViewController {

    @IBOutlet weak var topLine: NSLayoutConstraint!
    @IBOutlet weak var collView: UICollectionView!
    @IBOutlet weak var tabView: UITableView!
    @IBOutlet weak var seachTf: UITextField!
    @IBOutlet weak var topView: UIView!
    
    let identifyIR = "IntelligentRankingCell"
    let identifyTM = "TourismModuleColl"
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.topView.layer.cornerRadius = 20
        self.topView.layer.masksToBounds = true
        
        if SCREEN_HEIGHT >= 812 {
            self.topLine.constant = 88
        }else{
            self.topLine.constant = 64
        }
        
        self.tabView.dataSource = self
        self.tabView.delegate = self
        self.tabView.tableFooterView = UIView.init()
        self.tabView.rowHeight = 40
        self.tabView.register(UINib.init(nibName: "IntelligentRankingCell", bundle: nil), forCellReuseIdentifier: identifyIR)
        
        self.collView?.dataSource = self
        self.collView?.delegate = self
//        self.collView?.backgroundColor = UIColor.groupTableViewBackground
        let layout = UICollectionViewFlowLayout.init()
        layout.scrollDirection = .vertical
        
        layout.itemSize = .init(width: (SCREEN_WIDTH - 42 - 80) / 3, height: (SCREEN_WIDTH - 42 - 80) / 3 + 30)
        layout.minimumInteritemSpacing = 6
        layout.minimumLineSpacing = 10
        layout.sectionInset = UIEdgeInsets.init(top: 10, left: 15, bottom: 10, right: 15)
        self.collView?.isScrollEnabled = false
        self.collView?.collectionViewLayout = layout
        self.collView?.showsVerticalScrollIndicator = true
        
        self.collView?.register(UINib.init(nibName: "TourismModuleColl", bundle: nil), forCellWithReuseIdentifier: identifyTM)
    }


    @IBAction func cancelBtn(_ sender: UIButton) {
        self.navigationController?.popViewController(animated: true)
    }
    

}

extension ClassificationTouristController:UITableViewDataSource,UITableViewDelegate{
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: identifyIR) as! IntelligentRankingCell
        cell.selectionStyle = .none
        cell.contentView.backgroundColor = UIColor.groupTableViewBackground
        return cell
    }
    
    
}

extension ClassificationTouristController:UICollectionViewDataSource,UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 6
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell : TourismModuleColl = collectionView.dequeueReusableCell(withReuseIdentifier: identifyTM, for: indexPath) as! TourismModuleColl
        cell.img.image = UIImage.init(named: "图层5")
        return cell
    }
    
    
}
